﻿#include "../lib/src/basic/CServerListenerModule.h"
#include "../lib/src/game/CServerMainModule.h"
#include "../lib/src/game/MsgID.h"
#include "../lib/src/game/MsgStruct.h"

#include <stdio.h>

#pragma comment(lib, "../Debug/ComLib.lib")

int main(int argc, char* argv[]) {
	CServerMainModule serverModuleMain;
	construct_server_main(&serverModuleMain, "server module main");

	CServerListenerModule svr;
	construct_server_listener(&svr, "server listener", 5161, AS_MODULE(&serverModuleMain));
	svr.run(&svr);
	while (1) {
		char cmd[512] = {0};
		gets_s(cmd, sizeof(cmd));
		if (0 == strcmp("p1", cmd)) {
			for (int y = ITEM_HEIGHT_COUNT - 2; y < ITEM_HEIGHT_COUNT; ++y) {
				for (int x = 0; x < ITEM_WIDTH_COUNT - 1; ++x) {
					serverModuleMain.piles[y * ITEM_WIDTH_COUNT + x] = ATOM_SHAPE_NORMAL;
				}
			}
			CMsg msg = { MSG_ID_DEBUG_PILE1, 0};
			serverModuleMain.send_msg_to_all_users(&serverModuleMain, &msg);
		} else if (0 == strcmp("test res", cmd)) {
			ST_TEST_RES res = {{MSG_ID_TEST_RES, 1}};
			res.data[0] = 100;
			serverModuleMain.send_msg_to_all_users(&serverModuleMain, &res.msg);
		}
	}
	return 0;
}